﻿using System;
using System.ComponentModel;
using System.Linq;
using ProjectEuler.Extensions;
using ProjectEuler.Linq;

namespace ProjectEuler.Problems
{
    [EulerProblem(34, 40730)]
    [Description("Find the sum of all numbers which are equal to the sum of the factorial of their digits.")]
    internal sealed class Problem034 : EulerProblem
    {
        public override Object Solve()
        {
            return (from n in (3).To(999999)
                    where n == (n).DecimalDigits().Sum(d => d.Factorial())
                    select n).Sum();
        }
    }
}
